<?php

namespace app\teacher\controller;

use app\teacher\model\Thesis as ThesisModel;
use app\teacher\security\TchCheck as TchCheckLogic;
use app\teacher\security\Auth as AuthLogic;
use think\Controller;
use think\Session;

class ReviewList extends Controller
{
    /**
     * 登录界面显示，自动登录
     * @access public
     * @return mixed 返回登录视图
     */
    public function reviewList()
    {
        //检测教师登录情况
        $tchCheck = new TchCheckLogic();
        if ($tchCheck->check() == 1) {
            //检测是否有查看个人列表权限
            $auth = new AuthLogic();
            $username=Session::get('token')['tchUsername'];
            if ($auth->check('reviewlist', $username)) {
                $thesis = new ThesisModel();
                //定义需要查询的字段
                $field = 'tisId,tisTitle,tisSourceName,tisTypeName,tisMain,tisAsk';
                //显示题目状态
                $tisStatus=getSrvConfig()['srvStatus'];
                if($tisStatus==2){
                    switch ($tisStatus){
                        case 0:$tisStatus="系统停用";
                            break;
                        case 1:$tisStatus="申报中";
                            break;
                        case 2:$tisStatus="审核中";
                            break;
                        case 3:$tisStatus="修改中";
                            break;
                        case 4:$tisStatus="已通过";
                            break;
                    }
                    $result = $thesis::where('tisAuthor','<>',$username)->field($field)->select();
                    if ($result !== false) {
                        $this->assign('tisStatus',$tisStatus);
                        $this->assign('thesisList', $result);
                    } else {
                        return "查询配置出错，请稍后再试";
                    }
                }else{
                    return "现在不是审核阶段";
                }

            } else {
                return "错误500：您没有添加题目的权限";
            }
        } else {
            return "错误600：您的登录信息出现问题，请重新登录"
            . "<br>" . "1.您的帐号在其他地方登录"
            . "<br>" . "2.您在线时间过长（5小时以上）"
            . "<br>" . "3.令牌验证错误";
        }
        return $this->fetch('reviewList/reviewList');
    }
}